//
//  BHMoreFunCollectionViewCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/9.
//

import UIKit

class BHMoreFunCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var type_label: UILabel!
    
    @IBOutlet weak var name_label: UILabel!
    
    @IBOutlet weak var begain_time_label: UILabel!
    
    @IBOutlet weak var place_label: UILabel!
    
    @IBOutlet weak var distance_area_label: UILabel!
    
    @IBOutlet weak var typeWidth: NSLayoutConstraint!
    
    @IBOutlet weak var price_label: UILabel!
    
    var model: BHFunListInfoModel! {
        didSet {
            self.name_label.text = model.name
            self.begain_time_label.text = model.beginTime
            self.place_label.text = model.venueName
            if model.price.isEmpty == true || model.price == "0" || model.price == "0.0" || model.price == "0.00"  {
                self.price_label.text = "无需报名费"
            }else {
                self.price_label.text = "¥\(model.price)"

            }
            
            if BHLocationManager.shared.authed == true {
                self.distance_area_label.text = "\(model.showDistance) \(model.areaName)"
            }else {
                self.distance_area_label.text = model.areaName
            }
            if model.typeOneLabel.isEmpty == true && model.typeTwoLabel.isEmpty == true {
                self.type_label.isHidden = true
            }else {
                self.type_label.isHidden = false
                if model.typeTwoLabel.isEmpty == true {
                    self.type_label.text = model.typeOneLabel
                    self.typeWidth.constant = CGFloat((model.typeOneLabel.count*12)+20)
                }else {
                    self.type_label.text = model.typeTwoLabel
                    self.typeWidth.constant = CGFloat((model.typeTwoLabel.count*12)+20)
                }
            }
        }
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.type_label.addLayerCorner(2, 0.5, .color_cccccc)
    }

    static var moreFunHeight: CGFloat {
        get {
            return 130
        }
    }
}
